<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd">
<%@taglib prefix="s" uri="/struts-tags" %>
<%@ page import="com.onlineMIS.common.Common_util,java.util.Date,java.text.SimpleDateFormat" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title>千禧宝贝连锁店管理信息系统</title>
<%@ include file="../../../common/Style.jsp"%>
<script>
var dataGrid ;
$(document).ready(function(){
	parent.$.messager.progress('close'); 
	
	var params = $.serializeObject($('#basicDataForm'));

	dataGrid = $('#dataGrid').datagrid({
		url : 'basicDataJSON!getBasicData',
		queryParams: params,
		fit : true,
		border : false,
		checkOnSelect : false,
		selectOnCheck : false,
		singleSelect:true,
		nowrap : false,
		rownumbers : true,
		rowStyler: function(index,row){
			var style = "";
			if (row.status == 1)
				style += 'color:red;';

			return style;
		},
		columns : [ [ 
				{
				field : 'id',
				title : '费用ID',
				width : 80
			    },{
					field : 'expenseName',
					title : '费用名称',
					width : 120
				},{
					field : 'parentName',
					title : '上级目录',
					width : 120
				},{
					field : 'belongToS',
					title : '费用归属',
					width : 100
				},{
					field : 'sort',
					title : '排序',
					width : 80
				},{
					field : 'statusS',
					title : '状态',
					width : 80
				},{
					field : 'comment',
					title : '备注',
					width : 120
				},{
					field : 'createBy',
					title : '创建人',
					width : 80
				},{
					field : 'createTime',
					title : '创建时间',
					width : 160
				},{
					field : 'updateBy',
					title : '修改人',
					width : 80
				},{
					field : 'updateTime',
					title : '修改时间',
					width : 160
				},{
				field : 'action',
				title : '编辑',
				width : 60,
				formatter : function(value, row, index) {
					var str = '';
					str += $.formatString('<a href="#" onclick="EditExpenseType(\'{0}\');"><img border="0" src="{1}" title="编辑单位"/></a>', row.id, '<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/text_1.png');
					return str;
						}
						} ] ],
				toolbar : '#toolbar',
						});
					});

	function EditExpenseType(unitId) {

		var params = "formBean.basicData=expenseType";
		if (unitId != 0)
			params += "&formBean.basicDataId =" + unitId;

		$.modalDialog.opener_dataGrid = dataGrid;

		$.modalDialog({
			title : "添加/更新单位",
			width : 540,
			height : 380,
			modal : false,
			draggable : false,
			href : 'basicData!preAddBasicData?' + params,

		});
	}
	function refresh() {
		$('#dataGrid').datagrid('load', $.serializeObject($('#basicDataForm')));
	}
	function cancel(){
		$.modalDialog.handler.dialog('close');
	}
	function saveExpenseType(){
	    if (!$('#updateExpenseTypeForm').form('validate'))
	    	return ;
		else {
		    var params=$("#updateExpenseTypeForm").serialize();

	        $.post("basicDataJSON!updateExpenseType",params, updateExpenseTypeBKProcess,"json");	
		}
	}
	function updateExpenseTypeBKProcess(data){
		var response = data.response;
		var returnCode = response.returnCode;
		if (returnCode != SUCCESS)
			$.messager.alert('错误', response.message, 'error');
		else {
			$.modalDialog.handler.dialog('close');
			$("#dataGrid").datagrid('reload');
		}		
	}
	
</script>
</head>
<body>
	<div class="easyui-layout" border="false" style="height:680px">
		<div data-options="region:'north',border:false" style="height: 60px;">
			<%@ include file="ChooseBasicData.jsp"%>
		</div>
		<div data-options="region:'center',border:false">
				<table id="dataGrid">			       
		        </table>

			<div id="toolbar" style="display: none;">
		             <a onclick="EditExpenseType(0);" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'">添加</a>
                     <a onclick="refresh();" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-reload'">刷新</a>
	        </div>
		</div>
	</div>
</body>
</html>